package test.runtime2;

import service.network.NetworkCalculationService;
import materials.network.NetworkInterface;

public class Rechenvieh2 {

	NetworkInterface _ni;
	double _fehler;
	
	public Rechenvieh2(NetworkInterface ni){
		_ni = ni;
		_fehler = 0;
	}
	
	
	public void calculateInput(double[] inpvect){	
		NetworkCalculationService ncs = new NetworkCalculationService(_ni);
		double[] out = ncs.calculateInput(inpvect);	
		//System.out.println(inpvect[0] + " --- " + out[0] );
		//_ni.getWeigthMatrix(1).printMatrix();
		_fehler += Math.abs((inpvect[0] / 10.0) - (out[0]));
	}
	
	public double getFitness(){
		return (1 /_fehler);
	}
	
	
	public void resetFitness(){
		_fehler = 0;
	}
	
	public NetworkInterface getNet(){
		return _ni;
	}
	
	public double getFehler(){
		return _fehler;
	}
}
